import React, {Component} from 'react'
import '../css/App.css'

import {fetchUtils, Admin, Resource} from 'react-admin'
import {PostList, PostEdit, PostCreate, PostIcon} from '../ui/posts'
import newDataProvider from '../provider/dataProvider'
import authProvider from '../provider/authProvider'
import chineseMessages from 'ra-language-chinese'
import Login from '../component/login'
import LoginOut from '../component/loginOut'

// const dataProvider = newDataProvider('http://v.juhe.cn', (options = {
//     headers: new Headers({
//         Accept: 'application/json',
//     }),
// }) => {
//     return fetchUtils.fetchJson(options);
// });

/*设置语言开始*/
const messages = {
    ch: chineseMessages,
};
const chineseProvider = locale => messages[locale];


class App extends Component {
    render() {
        return (
            <Admin dataProvider={newDataProvider}
                   loginPage={Login}
                   authProvider={authProvider}
                   locale="ch"
                   i18nProvider={chineseProvider}>
                <Resource name="cook/query"
                          list={PostList}
                />
            </Admin>
        );
    }
}

export default App;
